package com.ecut.xzh.controller;


import com.ecut.xzh.dto.MarketDTO;
import com.ecut.xzh.result.Result;
import com.ecut.xzh.result.ScrollResult;
import com.ecut.xzh.service.MarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author XZH
 */
@RestController
@RequestMapping("/market")
@Slf4j
public class MarketController {

    @Resource
    private MarketService marketService;

    /**
     * 添加商品
     * @return
     */
    @PutMapping("/add")
    public Result addGoods(@RequestBody MarketDTO marketDTO){
        log.info("添加商品：{}",marketDTO);
        marketService.addGoods(marketDTO);
        return Result.success();
    }

    /**
     * 滚动查询
     * @param scrollNum
     * @return
     */
    @GetMapping("/scroll/{scrollNum}")
    public Result<ScrollResult> scroll(@PathVariable("scrollNum") Integer scrollNum){
        log.info("滚动查询页数:{}",scrollNum);
        ScrollResult scrollResult = marketService.scroll(scrollNum);
        return Result.success(scrollResult);
    }
}
